home *** CD-ROM | disk | FTP | other *** search
/ Super PC 35 / Super PC 35 (Shareware).iso / spc / WIN95 / CM95 / INTERNET.DLL / TEXT / WILAGENT next >
Encoding:
Text File  |  1996-03-20  |  2.3 KB  |  112 lines

  1. bOK = @TRUE
  2. szDial     = "<dialupname>"
  3. szPgmPath  = "<pgmpath>"
  4. szPgmDir   = "<pgmdir>"
  5. bNewHdrs   = <newhdrs>
  6. bSendMail  = <sendmail>
  7. ;bGetMail   = <getmail>
  8. bNewGroups = <newgroups>
  9. bCompact   = <compact>
  10. szErrDesc  = ""
  11. nWait      = 10 ; How many minutes to wait for Agent to finish its work
  12.  
  13.  
  14. ;Dial our host (unless user is on a direct connect)...
  15. hConn = 0
  16. if (szDial <> "")
  17.     hConn = SDialUp (szDial)
  18.     nErr = SGetLastErr ()
  19.     if (!hConn)
  20.         switch nErr
  21.             case @SErrNotFound
  22.             szErrDesc = "Couldn't connect to %szDial% - no such dial-up"
  23.  
  24.             case nErr ; <--default
  25.             szErrDesc = "Couldn't connect to %szDial% - error %nErr%"
  26.         endswitch
  27.         bOK = @FALSE
  28.         goto LogIt
  29.     else
  30.         if (nErr == @SAlready)
  31.             hConn = 0
  32.         endif
  33.     endif
  34. endif
  35.  
  36.  
  37. ; Run Agent & make it do things...
  38. szTitle = ""
  39. if (WinExist ("Free Agent")) then szTitle = "Free Agent"
  40. if (WinExist ("Agent")) then szTitle = "Agent"
  41. if (szTitle <> "")
  42.     WinActivate (szTitle)
  43. else
  44.     DirChange (szPgmDir)
  45.     Run (szPgmPath, "")
  46.     delay (6)
  47.     if (WinExist ("Free Agent")) then szTitle = "Free Agent"
  48.     if (WinExist ("Agent")) then szTitle = "Agent"
  49. endif
  50.  
  51.  
  52. ; Get new headers (if chosen)...
  53. if (bNewHdrs)
  54.     SendKeysTo (szTitle, "!on")
  55.     Delay (10)
  56. endif
  57.  
  58. ; Update the group list (if chosen)...
  59. if (bNewGroups)
  60.     SendKeysTo (szTitle, "!og")
  61.     Delay (10)
  62. endif
  63.  
  64. ; Get new mail (if chosen)...
  65. ;if (bGetMail)
  66. ;    SendKeysTo (szTitle, "???")
  67. ;    Delay (10)
  68. ;endif
  69.  
  70. ; Send outgoing mail/articles (if chosen)...
  71. if (bSendMail)
  72.     SendKeysTo (szTitle, "!op")
  73.     Delay (10)
  74. endif
  75.  
  76. ; Compact the database (if chosen)...
  77. ;if (bCompact)
  78. ;    SendKeysTo (szTitle, "!fc")
  79. ;endif
  80.  
  81.  
  82. ; Wait for nWait minutes, or till user kills off Agent manually...
  83. for n=1 to nWait * 6
  84.     if (WinExist (szTitle))
  85.         Delay (10)
  86.     endif
  87. next n
  88.  
  89.  
  90. ; If user hit Ctrl+Break, WIL will bring us here...
  91. :Cancel
  92.  
  93. ; Hang up...
  94. :HangUp
  95. if (hConn)
  96.     nRet = SHangUp (hConn)
  97. endif
  98.  
  99.  
  100. ; Log what we did...
  101. :LogIt
  102. if bOK == @TRUE
  103.     szLog = "Ran Agent"
  104. else
  105.     szLog = strcat ("Error attempting to automate Agent:", @CRLF, szErrDesc)
  106. endif
  107.  
  108. CMLogMessage (szLog)
  109. exit
  110.  
  111. ~
  112.